#include<iostream>
#include<assert.h>
using namespace std;
namespace bit
{
	template<class T>
	class vector
	{
		/*typedef T value_type;
		typedef value_type* iterator;
		typedef const value_type* const_iterator;
		iterator start;
		iterator finish;
		iterator end_of_storage;*/
		
	public:
		typedef T* iterator;
		typedef const T* iterator;
		iterator begin()
		{
			return _start;
		}

		iterator end()
		{
			return _finish;
		}

		vector()
			:_start(nullptr)
			,_finish(nullptr)
			,_endofstorage(nullptr)
		{}

		~vector()
		{
			delete[] _start;
			_start = _finish = _endofstorage = nullptr;
		}

		void push_back(const T& x)
		{
			if (_finsih == _endofstorage)
			{
				size_t sz = size();
				size_t cp=capacity = capacity() == 0 ? 4 : capacity() * 2;
				T* tmp = new T[cp];
				if (_start)
				{
					memcpy(tmp, _start, sizeof(T) * size());
					delete[] _start;
				}
				
				_start = tmp;
				_finish = _start+sz;
				_endofstorage = _start + cp;
			}
			*_finish = x;
			++_finish;
		}

		void insert(iterator pos, const T& x);
		void erase(iterator pos);
		T& operator[](size_t pos)
		{
			assert(pos < size());
			return _start[pos];
		}

		const T& operator[](size_t pos)const
		{
			assert(pos < size());
			return _start[pos];
		}

		size_t capacity()
		{
			return _endofstorage - _start;
		}

		size_t size()
		{
			return _finsih - _start;
		}
	private:
		iterator _start;
		iterator _finish;
		iterator _endofstorage;
	};

	void test_vector1()
	{
		vector<int> v;
		v.push_back(1);
		v.push_back(2);
		v.push_back(3);
		v.push_back(4);
		v.push_back(5);


		for (size_t i = 0; i < v.size(); i++)
		{
			cout << v[i] << " ";
		}
		cout << endl;

		vector<int>::iterator it = v.begin();

		for (it !=v.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;

		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << endl;
	}
}